﻿using pbvs.Calculations;
using pbvs.Data;
using pbvs.Models;
using pbvs.Models.ViewModels;
using System.Collections.Generic;
using System.Linq;

namespace pbvs.Services.ServiceExtensions
{
    public static class ReportServiceExtensions
    {
        public static ValuationReport ToValuationReport(this ValuationRequest value, VariablesFull vars)
        {
	        Valuation val = new Valuation(value.ToDomainModel(), vars);

            return new ValuationReport
            {
				CreatedDate = value.CreatedDt,
				FirstName = value.Client.FirstName,
				LastName = value.Client.LastName,
				Company = value.Client.CompanyName,
				Address = value.Client.Address,
				City = value.Client.City,
				State = value.Client.State,
				Zip = value.Client.Zip,
				ParticipantFirstName = value.ParticipantFirstName,
				ParticipantLastName = value.ParticipantLastName,
				SurvivorFirstName = value.SurvivorFirstName,
				SurvivorLastName = value.SurvivorLastName,
				Gender = value.Gender,
				ValuationDate = value.ValuationDate,
				Dob = value.Dob,
				RetirementDate = value.RetirementDate,
				MonthlyBenefit = value.BenefitAtRetirement,
				AnnuityType = value.AnnuityType,
				SurvivorDob = value.SurvivorDob,
				PresentValueAtProjectedDate = val.PresentValueAtProjectedDate,
				MaritalPortionOfPresentValue = val.MaritalPortionOfPresentValue
			};
        }

        public static IEnumerable<ValuationReport> ToValuationReports(this IEnumerable<ValuationRequest> value, VariablesFull vars)
        {
            return value.ToList().Select(n => n.ToValuationReport(vars));
        }
    }
}